<template>
	<view class="body">
		    <!-- 操作菜单 -->
			<paperLeftPopup 
			:show="show"
			@hiddenpopup="hiddenpopup"
			@showpopup="showpopup"
			@addfriend="addfriend"
			@clear="clear"
			/>
			
			<!-- 小纸条列表 -->
			<block v-for="(item,index) in list" :key="index">
				<paper-list :item="item" :index="index"/>
			</block>
	</view>
</template>

<script>
	import paperList from "../../components/paper/paper-list.vue";
	import paperLeftPopup from '../../components/paper/paper-left-popup.vue';
	export default {
		data() {
			return {
				show:false,
				list:[
				    {
						userpic:'../../static/demo/userpic/12.jpg',
						username:'昵称',
						time:'10:21',
						data:'我是信息',
						noreadnum: '123'
					},
					{
						userpic:'../../static/demo/userpic/12.jpg',
						username:'昵称',
						time:'10:21',
						data:'我是信息',
						noreadnum: '11'
					},
					{
						userpic:'../../static/demo/userpic/12.jpg',
						username:'昵称',
						time:'10:21',
						data:'我是信息',
						noreadnum: '9'
					},
					{
						userpic:'../../static/demo/userpic/12.jpg',
						username:'昵称',
						time:'10:21',
						data:'我是信息',
						noreadnum: '0'
					},
					{
						userpic:'../../static/demo/userpic/12.jpg',
						username:'昵称',
						time:'10:21',
						data:'我是信息',
						noreadnum: '8'
					}
				]
			}
		},
		methods: {
			// 监听导航按钮点击事件
			onNavigationBarButtonTap(e){
				switch (e.index){
					case 0:
						uni.navigateTo({
							url:'../user-list/user-list'
						})
						this.hiddenpopup();
						break;
					case 1:
					    this.showpopup();
						break;	
					default:
						break;
				}
				
			},
			// 加糗友
			addfriend(){
				console.log('加糗友');
				this.hiddenpopup();
			},
			// 清除缓存
			clear(){
				console.log('清除缓存');
				this.hiddenpopup();
			},
			hiddenpopup(){
				this.show = false;
			},
			showpopup(){
				this.show = true;
			}
		},
		components:{
			paperList,
			paperLeftPopup
		}
	}
</script>

<style scoped>
.body{
	padding: 0 20upx;
}
</style>
